# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer:
pkgname=coxeter
pkgver=3.0
pkgrel=1
pkgdesc="Tool for studying combinatorial aspects of Coxeter group theory"
url="http://math.univ-lyon1.fr/~ducloux/coxeter/coxeter3/english/coxeter3_e.html"
arch="all"
license="GPL-1.0-only"
source="https://archive.org/download/coxeter-$pkgver.tar.xz/coxeter-$pkgver.tar.xz
	add-sagemath-interface.patch
	makefile
	test-input
	test-output"
subpackages="$pkgname-dev $pkgname-libs"

prepare() {
	default_prepare
	cp "$srcdir"/makefile .
}

build() {
	export CXXFLAGS="${CXXFLAGS/-Os/-O3}" # gotta go fast
	make -e
}

check() {
	LD_LIBRARY_PATH=. ./coxeter < "$srcdir"/test-input > actual-test-output
	diff "$srcdir"/test-output actual-test-output
}

package() {
	install -Dm755 coxeter "$pkgdir"/usr/bin/coxeter
	install -Dm755 libcoxeter3.so.0.0.0 "$pkgdir"/usr/lib/libcoxeter3.so.0.0.0
	ln -s libcoxeter3.so.0.0.0 "$pkgdir"/usr/lib/libcoxeter3.so
	install -Dm644 -t "$pkgdir"/usr/include/coxeter ./*.h ./*.hpp
	install -dm755 "$pkgdir"/usr/share/coxeter
	cp -vR coxeter_matrices "$pkgdir"/usr/share/coxeter/.
	cp -vR headers "$pkgdir"/usr/share/coxeter/.
	cp -vR messages "$pkgdir"/usr/share/coxeter/.
}

sha512sums="
d7702ec7f84593aa2d6290e9405494f491f4a143be6db763f2a1974baffa6ab5b4cfeec4a0699ba37a547dd20e0c991ce9753778f0fb9a8b03c3a093f6bf7ebc  coxeter-3.0.tar.xz
5c76577ba110ca550756c5149067ed0c8ebfbea01888e922c826b5f919549784de7e0921cae4604221f123586b69740e677da3699f676ba40bd04fbcc0f68382  add-sagemath-interface.patch
dddce060808349d9849efd7446a139d54be8d57e2012079f96776ac85d9ef197a59d2e2c32ad950ca8cfa0cf1281d1912a31f828702edd923697cd67647f4e80  makefile
bca860dd0b717ea5cd7ba3213583f07a39f1e33451a53765db444f11a2e59a1e3d1eedb6465f6601dc67bfc30d856a793c6a05f65f53e10651509aeabebaaa91  test-input
52e7198f6ebeb05b9ddd00a280ab1e168e82f31e2124bebbac84d0bdc35096ab0caaedae7a0e58e25e1b327ed93754261254fc89a1a05589e5fd53282adc4101  test-output
"
